package com.game.server.message.proto.execute;

import com.comm.ISession;

import com.game.majiang.config.DataManager;
import com.game.majiang.logic.LogicClient;
import com.game.majiang.logic.LogicServer;
import com.game.server.db.entity.XyClubInfo;
import com.game.server.db.entity.XyClubMemberInfo;
import com.game.server.message.proto.in.AbstractXYfindPromotionInfoReq;
import com.game.server.message.proto.out.XYfindPromotionInfoRsp;

public class XYfindPromotionInfoReq extends AbstractXYfindPromotionInfoReq {

    @Override
    public void Execute(ISession session) {
        LogicClient client = (LogicClient) LogicServer.getInstance().getClient(session.getId());
        if (client != null && client.checkClick(msgcode)) {
            XYfindPromotionInfoRsp rsp = new XYfindPromotionInfoRsp();
            XyClubInfo xyClubInfo = DataManager.getInstance().getMapClub().get(this.clubid);
            if (xyClubInfo!=null) {
                XyClubMemberInfo xyClubMemberInfo = xyClubInfo.getPlayer().get(client.getUserId());
                if (xyClubMemberInfo!=null){
                    String shareurl = DataManager.getInstance().systemValue("AndroidDownloadLink");
                    String downPictureAddress = DataManager.getInstance().systemValue("AndroidDownloadCode");
                    rsp.setDownloadLink(shareurl);
                    rsp.setDownPictureAddress(downPictureAddress);
                    rsp.setIsPartner(xyClubMemberInfo.getIsAccessory());
                    if (xyClubMemberInfo.getIsAccessory()==1){
                        rsp.setPartnerId(xyClubMemberInfo.getPartner_id());
                    }
                }
            }
            client.Send(rsp);
        }
    }

}
